<%--
    Document   : orderdetail
    Created on : Sep 20, 2011, 6:52:08 PM
    Author     : Quangtv
--%>

<%@page import="java.net.URL"%>
<%@page import="java.io.File"%>
<%@page import="Assignment.BLO.Book_OrderBLO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Order Details</title>
        <link href="css/style.css" rel="stylesheet" type="text/css"/>
        <link href="css/bannerstyle.css" rel="stylesheet" type="text/css"/>
        <link href="css/TableCSS.css" rel="stylesheet" type="text/css"/>

        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

        <script type="text/javascript">
            function checkExitsUserName(isExits){
                if(isExits == "true"){
                    document.getElementById("username_error").style.visibility = "visible";
                    document.getElementById("username_error").textContent = "Username is already exits!";

                }else{
                    document.getElementById("username_error").style.visibility = "collapse";
                }
            }

            function setVisibility(showUser, isAdmin){
                if(showUser == "true"){
                    document.getElementById("user").style.visibility = "visible";
                    document.getElementById("loggeduser").style.visibility = "hidden";
                }else if(showUser == "false" && isAdmin == "true"){
                    document.getElementById("loggeduser").style.visibility = "visible";
                    document.getElementById("user").style.visibility = "hidden";
                    document.getElementById("user_link").textContent = "| Admin";
                    document.getElementById("user_link").href = "admin.jsp";
                }else if(showUser == "false" && isAdmin == "false"){
                    document.getElementById("loggeduser").style.visibility = "visible";
                    document.getElementById("user").style.visibility = "hidden";
                    document.getElementById("user_link").textContent = "| View Cart";
                    document.getElementById("user_link").href = "viewcart.jsp";
                }

                loadCombobox();
            }

            function checkSearch(){
                if (document.getElementById("searchText").value.toString().length == 0){
                    alert("Must input somrthing!")
                    return false;
                }else{
                    return true;
                }
            }
        </script>
        <%
                    String loggedUser = (String) session.getAttribute("USER");
                    String showUser = "";
                    String isAdmin = "";
                    if (loggedUser == null) {
                        showUser = "true";
                    } else {
                        showUser = "false";
                        isAdmin = (String) session.getAttribute("ISADMIN");
                        if (isAdmin == null || isAdmin == "false") {
                            isAdmin = "false";
                        } else {
                            isAdmin = "true";
                        }
                    }

                    Book_OrderBLO boBLO = new Book_OrderBLO();
                    String path = boBLO.getAllBookOrders();
                    URL url = (new File(path)).toURI().toURL();
                    String bOrderURL = url.toString();
        %>
    </head>
    <body onload='setVisibility("<%=showUser%>", "<%=isAdmin%>")'>
        <div id="header-wrap">
            <div id="header">
                <div style="margin:0px; text-align: left; float: left;"> <span style="color: #FFFFFF; font-family:'Arial Black',Gadget,sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -2px;"><a href="index.jsp" style="color: #FFF; text-decoration: none;" title="Awesomebooks.com">AWESOMEBOOKS</a></span> <a style="color: #FFF; font-size: 18px; font-family: Georgia, 'Times New Roman', Times, serif; font-style:italic; font-weight:normal; text-decoration: none;" href="index.jsp" title="Find your own book">Find your own book</a> 	</div>
                <ul class="menu">

                    <!-- Begin Simple Item Without Drop -->
                    <li class="">
                        <a href="newrelease.jsp">New Release</a>
                    </li>
                    <li class="">
                        <a href="bestseller.jsp">Best Seller</a>
                    </li>
                    <li class="">
                        <a href="bookreview.jsp">Books Review</a>
                    </li>

                    <li class="drop">
                        <a href="#">Catalogs</a>
                        <span class="toggle">&nbsp;</span>
                        <ul>
                            <li><a href="Controller?Action=Search&searchText=literature&Category=true">Literature</a></li>
                            <li><a href="Controller?Action=Search&searchText=life style&Category=true">Life Style</a></li>
                            <li><a href="Controller?Action=Search&searchText=tutorial&Category=true">Tutorial</a></li>
                            <li><a href="Controller?Action=Search&searchText=discovery&Category=true">Discovery</a></li>
                            <li><a href="Controller?Action=Search&searchText=science&Category=true">Science</a></li>
                            <li><a href="Controller?Action=Search&searchText=kids&Category=true">Kids</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div id="underheader">
                <form action="Controller" onsubmit="return checkSearch()" method="POST">
                    <span id="searchbox" style="width:50%">
                        <input id="searchText" name="searchText" type="text" style="width:250px; border:1px solid #333333" />
                        <input name="Action" type="submit" value="Search" id="button" />
                    </span>
                    <span id="user" style="width:50%">
                        <a href="login.jsp">Login</a> |
                        <a href="register.jsp">Register</a>
                    </span>
                    <span id="loggeduser" style="width:50%;position: relative; left: -180px; visibility: hidden">
                        <a><%=loggedUser%></a>
                        <a href="Controller?Action=Logout">(Logout)</a>
                        <a href="viewcart.jsp" id="user_link">| View Cart</a>
                    </span>
                </form>
            </div>
        </div>
        <center>
            <br/>
            <c:import var="bookURL" url="${sessionScope.BOOKURL}" />
            <c:import var="orderURL" url="${sessionScope.ORDERURL}" />
            <c:import var="bOrderURL" url="<%=bOrderURL%>" />
            <x:parse var="docBook" xml="${bookURL}" />
            <x:parse var="docOrder" xml="${orderURL}" />
            <x:parse var="docBOrder" xml="${bOrderURL}" />
            <c:set var="orderID" value="${param.orderID}" />

            <div id="registerForm">
                <form action="Controller" method="post">
                    <fieldset>
                        <legend>Order details</legend>
                        <x:set var="order" select="$docOrder//Order[orderID=$orderID]" />
                        <%--<div><label>[Order ID] <x:out select="$order/orderID" /></label></div>
                        <div><label>[Username] <x:out select="$order/username" /></label></div>
                        <div><label>[Order Date] <x:out select="$order/orderDate" /></label></div>
                        <div><label>[Delivery Date] <x:out select="$order/deliveryDate" /></label></div>
                        <div><label>[Total Price] <x:out select="$order/totalPrice" /></label></div>
                        <div><label>[Status] <x:out select="$order/status" /></label></div>--%>
                        <ul style="text-align: left">
                            <li>[Order ID] <x:out select="$order/orderID" /></li>
                            <li>[Username] <x:out select="$order/username" /></li>
                            <li>[Order Date] <x:out select="$order/orderDate" /></li>
                            <li>[Delivery Date] <x:out select="$order/deliveryDate" /></li>
                            <li>[Total Price] <x:out select="$order/totalPrice" /></li>
                            <li>[Status] <x:out select="$order/status" /></li>
                        </ul>
                        <div>
                            <table  width="90%" style="border: 1px #333333 solid">
                                <thead>
                                    <tr style="background-color: #333333; color: white">
                                        <th>ID</th>
                                        <th>Title</th>
                                        <th>Price</th>
                                        <th>Quantity</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <x:forEach var="bookOrder" select="$docBOrder//BookOrder[orderID=$orderID]">
                                        <x:set var="bookID" select="$bookOrder/bookID" />
                                        <tr style="background-color: #cccccc">
                                            <td style="height: 40px"><x:out select="$bookID" /></td>
                                            <td style="height: 40px"><x:out select="$docBook//Book[bookID=$bookID]/title" /></td>
                                            <td style="height: 40px"><x:out select="$docBook//Book[bookID=$bookID]/price" /></td>
                                            <td style="height: 40px"><x:out select="$bookOrder/quantity" /></td>
                                        </tr>
                                    </x:forEach>
                                </tbody>
                            </table>
                        </div>
                    </fieldset>
                </form>
            </div>
        </center>
        <br/>
    </body>
</html>
